CATROID-1106: GlideToPositionBrick - #5239
rinaschedl wants to merge 8 commits into
Conversation
| @@ -0,0 +1,75 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
|
|
|||
| <!-- | |||
There was a problem hiding this comment.
detekt found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
please fix all warnings first and have a look at the Unit Test Report, there are failing testcases. Not sure if they are related to these changes. Then i can do a review :) |
A new Brick (Feature) is created. The Brick has 3 options: -random position - the sprite glides to a random position -touch position - the player has to touch a position where the sprite then goes -other sprite position - the sprite glides and at the moment follows a other sprite till the other sprite stops. - this part is not finally discussed: may we change it so that the sprite goes to the startposition from the other sprite, if it moves too TestGlideToRandomPositionDestination Test; flact:red TestGlideToRandomPositionDestination flact:green; createGlidetoRandomPositionAction; Refactoring and knew Test: GlideBehavior, bove Tests are green show Brick in Bricklist with the correct attributs. Attributes don't work yet. changed all glide_to_.... to glide_to_position_... so to better distinguish between. last commit before PairProgramming Session with Thomas glideToTouchPosition ready, brick test by hand and the tests are grenn refactor the ActionTest: canceled all deprecated lines; correct misspellings; add GlideToOtherSpritePosition refactor GlideToRandomPositionAction.kt Refactoring all files that changed in the ticket Catroid-1106 Refactoring all files that changed in the ticket Catroid-1106
2ba8a8c to
23b5c77
Compare
…sts suddently failed and we do not have a koin base class
…e problem with the testpipeline
…ction for the GlideToPosition actions. Warnings of deprecated stays in the ActionFactory
…ction for the GlideToPosition actions. Warnings of deprecated stays in the ActionFactory
|
@hannesweilharter please start with CodeReview. |
hannesweilharter
left a comment
There was a problem hiding this comment.
Basically the new feature is working well, but i have a few suggestions, ptal into the inline comments :)
There are a few other things I noticed, please have a look:
-
Small Bug: Move new brick into a Forever brick with "Touch position": This works only once. I guess the correct behavior should be that the sprite should always move to the touch position when the user touches the screen.
-
The two failing testcases in
BricksXmlSerializerTeston the CI are actually related to the changes. The reason is: there is no alias registered forGlideToPositionBrick. To fix it just add this line inXStreamSerializer:xstream.alias("brick", GlideToPositionBrick.class); -
Please make sure the copyright year is up to date in every file
-
Please fix all the code style warnings.
There was a problem hiding this comment.
why deleting this file?
There was a problem hiding this comment.
I can't remember that I removed a file. What does this file normaly do?
There was a problem hiding this comment.
whats the purpose of this file?
There was a problem hiding this comment.
This file make sure that every coder, reviewer etc is using the same Java.Version in his IDE settings, so to reduce codeproblems according to different javaversions.
| case BrickValues.GLIDE_TO_RANDOM_POSITION: | ||
| GlideToRandomPositionAction randomAction = | ||
| action(GlideToRandomPositionAction.class); | ||
| randomAction.setScope(scope); | ||
| randomAction.setDuration(duration.interpretFloat(scope)); | ||
| return randomAction; |
There was a problem hiding this comment.
I would suggest setting the scope and duration after the switch statement to remove code duplication.
There was a problem hiding this comment.
There is no duplicated code, because in each case you call a different instance, there you set the scope etc.
| data class Scope( | ||
| val project: Project?, | ||
| val sprite: Sprite, | ||
| var sprite: Sprite, |
There was a problem hiding this comment.
why changing val to var?
There was a problem hiding this comment.
IMO it would make sense to introduce a common GlideToPositionAction parent class to reduce duplicated code between the three position-based glide actions. They all store a start position and current position etc.
There is also an already existing GlideToAction class which might contain some overlapping gliding logic. I haven't looked into the concrete behavior in detail, so please check whether the existing class can be reused somehow.
| if (spinnerSelection == BrickValues.GLIDE_TO_RANDOM_POSITION) { | ||
| spinner.setSelection(0) | ||
| } | ||
| if (spinnerSelection == BrickValues.GLIDE_TO_TOUCH_POSITION) { | ||
| spinner.setSelection(1) | ||
| } | ||
| if (spinnerSelection == BrickValues.GLIDE_TO_OTHER_SPRITE_POSITION) { | ||
| spinner.setSelection(destinationSprite) | ||
| } |
There was a problem hiding this comment.
| if (spinnerSelection == BrickValues.GLIDE_TO_RANDOM_POSITION) { | |
| spinner.setSelection(0) | |
| } | |
| if (spinnerSelection == BrickValues.GLIDE_TO_TOUCH_POSITION) { | |
| spinner.setSelection(1) | |
| } | |
| if (spinnerSelection == BrickValues.GLIDE_TO_OTHER_SPRITE_POSITION) { | |
| spinner.setSelection(destinationSprite) | |
| } | |
| when (spinnerSelection) { | |
| BrickValues.GLIDE_TO_RANDOM_POSITION -> | |
| spinner.setSelection(0) | |
| BrickValues.GLIDE_TO_TOUCH_POSITION -> | |
| spinner.setSelection(1) | |
| BrickValues.GLIDE_TO_OTHER_SPRITE_POSITION -> | |
| spinner.setSelection(destinationSprite) | |
| } |
There was a problem hiding this comment.
applied changes;
| if (string == context.getString(R.string.brick_glide_to_touch_position)) { | ||
| spinnerSelection = BrickValues.GLIDE_TO_TOUCH_POSITION | ||
| destinationSprite = null | ||
| } | ||
|
|
||
| if (string == context.getString(R.string.brick_glide_to_random_position)) { | ||
| spinnerSelection = BrickValues.GLIDE_TO_RANDOM_POSITION | ||
| destinationSprite = null | ||
| } |
There was a problem hiding this comment.
| if (string == context.getString(R.string.brick_glide_to_touch_position)) { | |
| spinnerSelection = BrickValues.GLIDE_TO_TOUCH_POSITION | |
| destinationSprite = null | |
| } | |
| if (string == context.getString(R.string.brick_glide_to_random_position)) { | |
| spinnerSelection = BrickValues.GLIDE_TO_RANDOM_POSITION | |
| destinationSprite = null | |
| } | |
| when (string) { | |
| context.getString(R.string.brick_glide_to_touch_position) -> { | |
| spinnerSelection = BrickValues.GLIDE_TO_TOUCH_POSITION | |
| destinationSprite = null | |
| } | |
| context.getString(R.string.brick_glide_to_random_position) -> { | |
| spinnerSelection = BrickValues.GLIDE_TO_RANDOM_POSITION | |
| destinationSprite = null | |
| } | |
| } |
| BrickValues.Y_POSITION, | ||
| BrickValues.GLIDE_SECONDS | ||
| ) | ||
| GLIDE_SECONDS) |
There was a problem hiding this comment.
| GLIDE_SECONDS) | |
| BrickValues.GLIDE_SECONDS |
to stay consistent
|



https://catrobat.atlassian.net/browse/CATROID-1106
A new Brick (Feature) is created.
Brick Behavior:
The Brick has 3 options:
-random position
- the sprite glides to a random position
-touch position
- the player has to touch a position where the sprite then goes
-other sprite position
- the sprite glides (and at the moment follows) a other sprite till the other sprite stops.
- this part is not finally discussed: may we change it so that the sprite goes to the startposition from the other sprite and don't follow at all.
Program changes:
create 3 Actions and 3 Actionstest, GlideToPositionBrick, brick_glide_to_position
changes in BrickValue, ActionFactory
Commitlist during coding:
TestGlideToRandomPositionDestination Test; flact:red
TestGlideToRandomPositionDestination flact:green; createGlidetoRandomPositionAction;
Refactoring and knew Test: GlideBehavior, bove Tests are green
show Brick in Bricklist with the correct attributs. Attributes don't work yet.
changed all glide_to_.... to glide_to_position_... so to better distinguish between.
last commit before PairProgramming Session with Thomas
glideToTouchPosition ready, brick test by hand and the tests are grenn
refactor the ActionTest: canceled all deprecated lines; correct misspellings;
add GlideToOtherSpritePosition
refactor GlideToRandomPositionAction.kt
Refactoring all files that changed in the ticket Catroid-1106
Your checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.